home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
uucp
/
AM114src.lha
/
show.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-08
|
5KB
|
245 lines
/*
*
* AM --- AmigaMail
* (C) 1991, 1992 by Christian Riede
*
* AM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY. No author or distributor accepts responsibility to anyone
* for the consequences of using it or for whether it serves any
* particular purpose or works at all, unless he says so in writing.
* Refer to the GNU General Public License, Version 1, for full details.
*
* Everyone is granted permission to copy, modify and redistribute AM,
* but only under the conditions described in the GNU General Public
* License, Version 1. A copy of this license is supposed to have been
* given to you along with AM so you can know your rights and responsi-
* bilities. It should be in a file named COPYING. Among other things,
* the copyright notice and this notice must be preserved on all copies.
*
*
*
*/
#include "am.h"
/* extract realname from address, if exists */
/* provide buffer in t, pointer to t containing the realname if exists */
/* or the username is returned */
/* attention: t does not necessarily contain the realname on return */
char *GetRealname(char *s,char *t)
{
char *savet;
int klammer = 0;
int quote = FALSE;
int esc = FALSE;
savet = t;
while (*s)
{
switch(*s)
{
case '(':
if (klammer) *t++=*s;
else t = savet;
klammer++;
break;
case ')':
if (klammer>1) *t++ = *s;
if (klammer>0) klammer--;
break;
case '<':
if (!quote)
goto done;
break;
case '"':
if (!esc)
quote = !quote;
default:
*t++=*s;
break;
}
if (*s=='\\') {if (!esc) esc = TRUE;} else esc = FALSE;
s++;
}
done:
*t=0;
return(savet);
}
/* extract username from address, if exists */
/* provide buffer in t, pointer to t containing the username */
char *GetUsername(char *s,char *t)
{
char *savet;
savet = t;
while (*s)
{
switch(*s)
{
case '<':
t = savet;
break;
case '>':
goto done;
break;
case '(':
goto done;
break;
default:
*t++=*s;
break;
}
s++;
}
done:
*t=0;
return(savet);
}
void ShowAll(struct List *Mailbox)
{
char RealFromName[160];
char RealToName[160];
struct Mail *Mail;
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
sprintf(Mail->DisplayText,"%c(%04ld) Fr:%-18.18s To:%-18.18s Subj:%-100.100s",
/* read? */
(Mail->read&MAIL_READ)?('R'):(' '),
/* Number */
Mail->Number,
/* From */
(*Mail->From)?
(GetRealname(Mail->From,RealFromName)):("none"),
/* To */
(*Mail->To)?
(GetRealname(Mail->To,RealToName)):("none"),
/* Subject */
(*Mail->Subject)?
(Mail->Subject):("none")
); /* of sprintf */
}
}
void ShowSubject(struct List *Mailbox)
{
struct Mail *Mail;
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
if (*Mail->Subject)
sprintf(Mail->DisplayText,"%c(%04ld) Subject: %-142.142s",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number,Mail->Subject);
else
sprintf(Mail->DisplayText,"%c(%04ld) Subject: (none)",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number);
}
}
void ShowFrom(struct List *Mailbox)
{
struct Mail *Mail;
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
if (*Mail->From)
sprintf(Mail->DisplayText,"%c(%04ld) From: %-145.145s",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number,Mail->From);
else
sprintf(Mail->DisplayText,"%c(%04ld) From: (none)",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number);
}
}
void ShowTo(struct List *Mailbox)
{
struct Mail *Mail;
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
if (*Mail->To)
sprintf(Mail->DisplayText,"%c(%04ld) To: %-147.147s",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number,Mail->To);
else
sprintf(Mail->DisplayText,"%c(%04ld) To: (none)",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number);
}
}
void ShowDate(struct List *Mailbox)
{
struct Mail *Mail;
char Date[60];
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
if (Mail->Date)
sprintf(Mail->DisplayText,"%c(%04ld) Date: %-145.145s",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number,DateTime(Mail->Date,Date));
else
sprintf(Mail->DisplayText,"%c(%04ld) Date: (none)",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number);
}
}
void ShowMsgId(struct List *Mailbox)
{
struct Mail *Mail;
for (Mail=(struct Mail *)Mailbox->lh_Head;
Mail->m_Node.ln_Succ;
Mail=(struct Mail *)Mail->m_Node.ln_Succ)
{
Mail->m_SelectNode.ln_Name = Mail->DisplayText;
if (*Mail->MsgId)
sprintf(Mail->DisplayText,"%c(%04ld) Msg-Id: %-143.143s",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number,Mail->MsgId);
else
sprintf(Mail->DisplayText,"%c(%04ld) Msg-Id: (none)",
(Mail->read&MAIL_READ)?('R'):(' '),
Mail->Number);
}
}